/**
 * 公用参数
 */
var name='';//科室名称
var code=""
var pcode=""
var hostcode=""


/**
 * 默认加载
 * @type {{init: Window.process.init, public: Window.process.public}}
 */
window.process = {
    init: function () {
        this.initData();
    },
    initData:function () {
        var paramsData = getUrlParamsCode();
        name= paramsData['name'];
        code= paramsData['code'];
        pcode= paramsData['pcode'];
        hostcode= paramsData['hostcode'];
        if(name){
            $('.header .title').text(name)
            this.load()
        }

    },
    load(){
        let api='/appRegsterMarks/find'
        let data={
            hostcode:hostcode,
            deptcode1:code,
            deptcode2:pcode,
            doctorcode:'',
            begindate:getNowFormatDate(),
            enddate:get7FormatDate(7)
        }
        postAjax(api,data,this.callbackLoad,this) 
    },
    callbackLoad(data,that){
        var temp_p=[]
        var temp_z=[]
        for(var i=0;i<data.length;i++){
            if(data[i].titletype=="1"){
                temp_p.push(data[i])
            }else{
                temp_z.push(data[i])
            }
        }
        var Data={
            temp_p:temp_p,
            temp_z:temp_z
        };
        var listHtml = template('list_data', Data);
        $("#list_data_content").html(listHtml);
        that.public();

    },
    public: function () {
        $('.temp_z').eq(0).show();
        //专家tab切换
        $('.list_z li').click(function () {
            var index=$(this).index()
            $('.tabBar li').removeClass('on')
            $(this).addClass('on')
            $('.tabList').hide()
            $('.temp_z').eq(index).show()
        });
         //普通tab切换
         $('.list_p li').click(function () {
            var index=$(this).index()
            $('.tabBar li').removeClass('on')
            $(this).addClass('on')
            $('.tabList').hide()
            $('.temp_p').eq(index).show()
        });

        //收藏
        $('.collect').click(function () {
           if($(this).hasClass('on')){
               $.toast("取消收藏", "text");
               $(this).removeClass('on');
           }else{
               $.toast("收藏成功", "text");
               $(this).addClass('on');
           }
        });

        //进入预约挂号
        $('.m3 .btn').click(function () {
           var state=$(this).attr('data-name');
            if(!state){
                window.location.href='make_detail.html'
            }

        });

    }
};

/**
 * 启动方法执行
 */
process.init();



